class Solution {
public:
    int numJewelsInStones(string jewels, string stones) {
        int hash[128] = { 0 };
        int ret = 0;
        for (auto& ch : jewels) hash[ch]++;
        for (auto& ch : stones)
        {
            if (hash[ch])
                ret++;
        }
        return ret;
    }
};
class Solution {
public:
    bool isHappy(int n) {
        int slow = n, fast = bitsum(n);
        while (slow != fast)
        {
            slow = bitsum(slow);
            fast = bitsum(bitsum(fast));
        }
        return slow == 1;
    }
    int bitsum(int n)
    {
        int sum = 0;
        while (n)
        {
            int tmp = n % 10;
            sum += tmp * tmp;
            n /= 10;
        }
        return sum;
    }
};